<?php
class Html extends dpComponent
{
	public static function registerEditorJs()
	{
		$js  = '<script type="text/javascript" src="'.ROOT.'public/ue/editor_config.js"></script>';
		$js .= '<script type="text/javascript" src="'.ROOT.'public/ue/editor_all_min.js"></script>';
		return $js;
	}

	public static function uploadOneImg($con_id, $bd_con_id, $value = '', $name = 'image', $id = 1)
	{
		$html = self::registerEditorJs();
$html .= <<<EOF
<input type="button" class="button" value="上传图片" id="upImage" />
<style type="text/css">
#edui{$id}{display:none}
</style>
<script type="text/javascript">
	$(function(){
		$('#{$con_id}').html('<input type="text" readonly="readonly" value="{$value}" id="upimg" name="image" />');
		uploadImage = new UE.ui.Editor({toolbars:[['insertimage']],wordCount:false,elementPathEnabled:false});
		uploadImage.render("{$bd_con_id}");
		uploadImage.ready(function(){});
		$('#upImage').click(function(){
			d = uploadImage.getDialog("insertimage");
		    d.render();
		    d.open();
		});
		uploadImage.addListener('beforeInsertImage', function(t, arg){
	    	$('#upimg').val(arg[0].src);
	    	uploadImage.removeListener('beforeInsertImage', function(){});
	    });
		$('.edui-editor').hide();
	})
</script>
EOF;
		return $html;
	}
}
?>